<template>
	<view>
		<view class="boxes" v-for="(item,index) in list" :key="index" @click.stop="detail(item.id)">
			<view class="uniBtn box">
				<view>订单号：{{item.id}}</view>
				<view class="stu" v-if="item.status==0">待支付</view>
				<view class="stu" v-else-if="item.status==1">已付款</view>
				<view class="stu" v-else>已取消</view>
			</view>
			<view class="uniFlex2 box2">
				<view>患者姓名</view>
				<view>{{item.name}}</view>
			</view>
			<view class="uniFlex2 box2">
				<view>收费项目</view>
				<view>{{item.item}}</view>
			</view>
			<view class="uniBtn box3">
				<view class="last" v-if="item.status==1 && item.num > 0" @click.stop="verify(item.id)">核 验</view>
				<view class="last2" v-if="item.status==1 && item.num < 1" @click.stop="renew(item)">续 费</view>
				
				<view v-if="item.status==0"></view>
				<view class="last1" v-if="item.status==0" @click.stop="pay(item.id)">立即支付</view>
				<!-- <view class="last2" v-else-if="item.status==2" @click.stop="del(item.id)">删除记录</view> -->
			</view>
		</view>
		
		<drag-button :isDock="true" @btnClick="btnClick" />
	</view>
</template>

<script>
	import {
		wzflist
	} from '@/request/api.js'
	import dragButton from "@/components/drag-button/drag-button.vue";
	export default {
		data() {
			return {
				// 上拉加载
				page: 1,
				pages: 0,
				list: []
			}
		},
		onShow() {
			this.page = 1;
			this.list = [];
			this.getList(1);
		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			this.page++;
			if (this.page > this.pages) {
				uni.hideNavigationBarLoading();
				uni.showToast({
					title: '暂无更多数据',
					icon: 'none'
				})
			} else {
				this.getList(this.page);
			}
		},
		methods: {
			btnClick(){
				uni.navigateTo({
					url:'/pages/outside/outside2'
				})
			},
			// 详情
			detail(id){
				uni.navigateTo({
					url:'./detail?id='+id
				})
			},
			// 支付
			pay(id){
				uni.navigateTo({
					url:'./pay?id='+id
				})
			},
			// 核验
			verify(id){
				uni.navigateTo({
					url:'./verify?id='+id
				})
			},
			// 续费
			renew(items){
				uni.setStorageSync('outsideMsg',JSON.parse(items.datastr))
				uni.navigateTo({
					url:'./renew?id='+items.id+'&remark='+items.remark
				})
			},
			// 删除
			del(id){
				
			},
			// 列表
			getList(page) {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				wzflist({
					page: page,
					listRows: 10,
				}).then(res => {
					this.pages = res.totalPages;
					if (this.page == 1) {
						this.list = res.data;
						if (this.list.length === 0 || this.list.length === '0') {
							uni.showToast({
								icon: 'none',
								duration: 3000,
								title: '暂无数据'
							});
							return
						}
					} else {
						this.list = this.list.concat(res.data);
					}
					uni.hideLoading()
					uni.hideNavigationBarLoading()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #f8f8f8;
	}
	.boxes{
		background: #ffffff;
		margin: 20upx 0;
		padding: 20upx 30upx;
		font-size: 28upx;
		color: #000;
		
		.box{
			border-bottom: 1px solid #eee;
			padding-bottom: 20upx;
			
			view:first-child{
				color: #000;
				font-weight: 520;
			}
			view:last-child{
				color: #F63B18;
				background-color: #FDF4F5;
				border-radius: 30upx;
				padding: 10upx 26upx;
				font-size: 24upx;
			}
		}
		.box2{
			margin: 30upx 0;
			
			view:first-child{
				color: #797979;
				width: 160upx;
			}
			view:last-child{
				flex: 1;
			}
		}
		.box3{
			margin: 30upx 0;
			
			.last{
				color: #6996FE;
				font-size: 24upx;
				border:1px solid #6996FE;
				border-radius: 26upx;
				padding: 8upx 30upx;
			}
			.last1{
				background-color: #6996FE;
				color: #fff;
				border-radius: 40upx;
				padding: 15upx 30upx;
			}
			.last2{
				border: 1px solid #F63B18;
				color: #F63B18;
				border-radius: 40upx;
				padding: 8upx 30upx;
			}
		}
	}
</style>
